package com.charlie.beans;

import java.io.Serializable;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.xml.bind.annotation.XmlRootElement;

/**
 *
 * @author Вова
 */
@Entity
@Table(name = "USERS_ROLE")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "UsersRole.findAll", query = "SELECT u FROM UsersRole u"),
    @NamedQuery(name = "UsersRole.findByUsersRoleId", query = "SELECT u FROM UsersRole u WHERE u.usersRoleId = :usersRoleId")})
public class UsersRole implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @NotNull
    @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "USERS_ROLE_SEQ")
    @SequenceGenerator(name = "USERS_ROLE_SEQ", sequenceName = "USERS_ROLE_USERS_ROLE_ID_SEQ", allocationSize = 1)
    @Column(name = "USERS_ROLE_ID")
    private Integer usersRoleId;
    @JoinColumn(name = "USERS_ID", referencedColumnName = "USERS_ID")
    @ManyToOne(optional = false)
    private Users usersId;
    @JoinColumn(name = "ROLES_ID", referencedColumnName = "ROLES_ID")
    @ManyToOne(optional = false)
    private Roles rolesId;

    public UsersRole() {
    }

    public UsersRole(Integer usersRoleId) {
        this.usersRoleId = usersRoleId;
    }

    public Integer getUsersRoleId() {
        return usersRoleId;
    }

    public void setUsersRoleId(Integer usersRoleId) {
        this.usersRoleId = usersRoleId;
    }

    public Users getUsersId() {
        return usersId;
    }

    public void setUsersId(Users usersId) {
        this.usersId = usersId;
    }

    public Roles getRolesId() {
        return rolesId;
    }

    public void setRolesId(Roles rolesId) {
        this.rolesId = rolesId;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (usersRoleId != null ? usersRoleId.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof UsersRole)) {
            return false;
        }
        UsersRole other = (UsersRole) object;
        if ((this.usersRoleId == null && other.usersRoleId != null) || (this.usersRoleId != null && !this.usersRoleId.equals(other.usersRoleId))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.charlie.beans.UsersRole[ usersRoleId=" + usersRoleId + " ]";
    }
    
}
